// miniprogram/pages/mine/mine.js
let app = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfoData: {},

    isAuth: false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  onShow() {
    this.getUserInfo();
    this.setData({
      isAuth: app.globalData.isAuth
    })
  },

  goMyBooking() {
    wx.navigateTo({
      url: '../myBooking/myBookiing',
    })
  },

  // 获取用户信息
  getUserInfo() {
    if (app.globalData.isAuth) {
        wx.getUserInfo({
          success: res => {
            this.setData({
              userInfoData: res.userInfo
            })
          }
        })
    }
  },

  // 获取用户授权信息
  getUserAuthInfo(res) {
    if (res.detail.userInfo) {
      app.globalData.isAuth = true;
      this.setData({
        isAuth: true,
        userInfoData: res.detail.isAuth
      });
    }
  }
})